<%@ Control Language="C#" ClassName="Dealers" Inherits="Dimok.Web.UI.TableControl" %>
<script runat="server">
	protected override void OnLoad(EventArgs e) {
		base.OnLoad(e);
		grvSP.RowInserting += new EventHandler<GridViewInsertEventArgs>(grvSP_RowInserting);
	}

	void grvSP_RowInserting(object sender, GridViewInsertEventArgs e) {
		e.InsertingValues["DealerID"] = grv.SelectedValue;
	}
</script>
<style>
LABEL.NoName {color:DarkRed;}
</style>
<table>
<tr><td>
<ajaxtk:CollapsiblePanelExtender runat="server" ID="cpeCBT"
	TargetControlID="pnlCBT"
	CollapseControlID="pnlCBTHeader" ExpandControlID="pnlCBTHeader"
	TextLabelID="lblCBTLabel"
	ImageControlID="imgCBTPanel"
	CollapsedImage="~/images/Buttons/expand.jpg" ExpandedImage="~/images/Buttons/collapse.jpg"
	Collapsed="false"	CollapsedText="" ExpandedText=""
	SuppressPostBack="true"
></ajaxtk:CollapsiblePanelExtender>
<asp:Panel ID="pnlCBTHeader" CssClass="PanelHeaderBlue" style="width:100%" runat="server">
<table cellPadding="0" cellSpacing="0"><tr>
<th Width="1px"><asp:Image ID="imgCBTPanel" ImageUrl="~/images/Buttons/expand.jpg" runat="server" />
<td nowrap><label ID="lblCBTLabel" runat="server">Dealers List</label></td>
</tr></table>
</asp:Panel> 
<asp:Panel ID="pnlCBT" runat="server" CssClass="PannelContent">
<asp:UpdatePanel ID="upCBT" UpdateMode="Always" runat="server">
	<ContentTemplate>
		<UI:GridViewEx ID="grv" runat="server" AutoGenerateColumns="False" DataSourceID="ds"
			ShowFooter="True" AllowSorting="True" sel
			DataKeyNames="ID"
			>
			<Columns>

				<!-- #include virtual = "~/Controls/_FieldTemplates/Name.txt" -->

		<asp:TemplateField HeaderText="Short Name" SortExpression="ShortName">
			<ItemTemplate><%#Eval("ShortName")%></ItemTemplate>
			<EditItemTemplate><asp:TextBox ID="txtShortName" Text='<%#Bind("ShortName")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate><asp:TextBox ID="ShortName" runat="server" /></FooterTemplate>
		</asp:TemplateField>

		<asp:TemplateField HeaderText="Usix ID" SortExpression="UsixID">
			<ItemTemplate><%#Eval("UsixID")%></ItemTemplate>
			<EditItemTemplate><asp:TextBox ID="txtUsixID" Text='<%#Bind("UsixID")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate></FooterTemplate>
		</asp:TemplateField>

		<asp:TemplateField HeaderText="Group" SortExpression="DealerCode">
			<ItemTemplate><%#Eval("DealerCode")%></ItemTemplate>
			<EditItemTemplate><asp:TextBox ID="txtDealerCode" Text='<%#Bind("DealerCode")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate><asp:TextBox ID="DealerCode" runat="server" /></FooterTemplate>
		</asp:TemplateField>

		<asp:TemplateField HeaderText="<span title='Is Independent'>Ind</span>" SortExpression="IsIndependent">
			<ItemTemplate><%#Eval("IsIndependent")%></ItemTemplate>
			<EditItemTemplate><asp:CheckBox ID="txtIsIndependent" Checked='<%#Bind("IsIndependent")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate><asp:CheckBox ID="IsIndependent" runat="server" /></FooterTemplate>
		</asp:TemplateField>

		<asp:TemplateField HeaderText="Street" SortExpression="Street">
			<ItemTemplate><%#Eval("Street")%></ItemTemplate>
			<EditItemTemplate><asp:TextBox ID="txtStreet" Text='<%#Bind("Street")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate><asp:TextBox ID="Street" runat="server" /></FooterTemplate>
		</asp:TemplateField>

		<asp:TemplateField HeaderText="City" SortExpression="City">
			<ItemTemplate><%#Eval("City")%></ItemTemplate>
			<EditItemTemplate><asp:TextBox ID="txtCity" Text='<%#Bind("City")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate><asp:TextBox ID="City" runat="server" /></FooterTemplate>
		</asp:TemplateField>

		<asp:TemplateField HeaderText="State" SortExpression="State">
			<ItemTemplate><%#Eval("State")%></ItemTemplate>
			<EditItemTemplate><asp:TextBox ID="txtState" Text='<%#Bind("State")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate><asp:TextBox ID="State" runat="server" /></FooterTemplate>
		</asp:TemplateField>

		<asp:TemplateField HeaderText="Zip" SortExpression="Zip">
			<ItemTemplate><%#Eval("Zip")%></ItemTemplate>
			<EditItemTemplate><asp:TextBox ID="txtZip" Text='<%#Bind("Zip")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate><asp:TextBox ID="Zip" runat="server" /></FooterTemplate>
		</asp:TemplateField>

<%--		<asp:TemplateField HeaderText="USIX Dealer" SortExpression="Dealer_U">
			<ItemTemplate><%#Eval("Dealer_U")%></ItemTemplate>
			<EditItemTemplate>
				<ds:DealersToMatchFromUsixDataSource OrderBys="Distance DESC" Name='<%#Eval("Name")%>' MinDistance="75" id="dsDealerInUsix" EmtyRowPolicy="None" runat="server" />
				<asp:DropDownList ID="selUsixID" SelectedValue='<%#Bind("UsixID")%>' DataSourceID="dsDealerInUsix" DataTextField="Info" DataValueField="Dealer Code" AppendDataBoundItems="true" runat="server">
					<asp:ListItem Text="Select Usix ID" Value="" />
				</asp:DropDownList>
			</EditItemTemplate>
		</asp:TemplateField>
--%>
			</Columns>
		</UI:GridViewEx>

		<UI:GridViewEx ID="grvSP" runat="server" AutoGenerateColumns="False" DataSourceID="dsSP"
			ShowFooter="True" AllowSorting="True" Caption="Contacts"
			DataKeyNames="ID"
			>
			<Columns>

		<asp:TemplateField HeaderText="Name" SortExpression="Name">
			<ItemTemplate><%#Eval("Name")%><label Visible='<%#(Eval("Name")+"")=="" && int.Parse("0"+Eval("DealerID"))>0%>' Class="NoName" RunAt="server">Enter Name Here</label></ItemTemplate>
			<EditItemTemplate><asp:TextBox ID="txtName" Text='<%#Bind("Name")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate><asp:TextBox ID="Name" runat="server" /></FooterTemplate>
		</asp:TemplateField>

		<asp:TemplateField HeaderText="Email" SortExpression="Email">
			<ItemTemplate><%#Eval("Email")%></ItemTemplate>
			<EditItemTemplate><asp:TextBox ID="txtEmail" Text='<%#Bind("Email")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate><asp:TextBox ID="Email" runat="server" /></FooterTemplate>
		</asp:TemplateField>

		<asp:TemplateField HeaderText="Phone" SortExpression="Phone">
			<ItemTemplate><%#Eval("Phone")%></ItemTemplate>
			<EditItemTemplate><asp:TextBox ID="txtPhone" Text='<%#Bind("Phone")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate><asp:TextBox ID="Phone" runat="server" /></FooterTemplate>
		</asp:TemplateField>

		<asp:TemplateField HeaderText="Cell" SortExpression="Cell">
			<ItemTemplate><%#Eval("Cell")%></ItemTemplate>
			<EditItemTemplate><asp:TextBox ID="txtCell" Text='<%#Bind("Cell")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate><asp:TextBox ID="Cell" runat="server" /></FooterTemplate>
		</asp:TemplateField>

		<asp:TemplateField HeaderText="Priority" SortExpression="Priority">
			<ItemTemplate><%#Eval("Priority")%></ItemTemplate>
			<EditItemTemplate><asp:TextBox ID="txtPriority" Text='<%#Bind("Priority")%>' runat="server" /></EditItemTemplate>
			<FooterTemplate><asp:TextBox ID="Priority" runat="server" /></FooterTemplate>
		</asp:TemplateField>

			</Columns>
		</UI:GridViewEx>

	</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</table>
<DS:DealersDataSource ID="ds" Filter="ID > 0" runat="server" />
<DS:Dealer_SalesPersonsDataSource ID="dsSP" runat="server">
	<SelectParameters>
		<asp:ControlParameter ControlID="grv" Name="DealerID" PropertyName="SelectedValue" Type="Int32" DefaultValue="-100" />
	</SelectParameters>
</DS:Dealer_SalesPersonsDataSource>
